Kinetis SDK Demo Applications User Guide  1.0.0-beta
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ADC Period Sample User Guide

User guide on how to customize this application for different configurations. More...

ADC Period Sample User Guide

Getting Started

  1. To run this demo, a sine wave signal input is required. Generally, you can use Function Generator to get such signal. The input signal should meet the following requirement:
    • sine wave signal
    • High amplitude: 0 V to 3.3 V
    • Low amplitude: 0 V to 3.3 V
    • Frequency: fixed to 50 Hz; If you want to change the input signal frequency configurations in the demo code, see the next section.
  2. Connect the input signal to the following pin:
    • TWR-K64F120M: pin 17 in J4 as ADC0_DP0
    • FRDM-K64F120M: pin 1 in J26 as ADC0_DP1
  3. Open the UART console on PC.
  4. Download and run the program on the target.
  5. The input signal wave form, the high/low amplitude is displayed on the console.
  6. If using the GCC built out binary, please use JLINK connecting JTAG port to do debug. Also the debug UART must be connected out from Pin1 J10 for Rx, and Pin2 J15 for Tx (e.g TWR-K60F120M)

Default configurations

ADC Configurations

  • Clock source: bus clock
  • VRef: VREFH/L 3.3 V
  • Resolution: 16 bit single-ended
  • Channel: ADC0_DP0/DP1
  • Hardware Trigger: Period Interrupt Timer0

Sample frequency

The default sample rate is 50 Hz * 100, which enables the demo application to get 100 samples per period. If you want to change the sample rate, see the next section.

HOWTO Customization

This demo application is customizable to show different kinds of input signal wave.

Configure the number of samples

Printing of the signal wave shape depends on the console size. A console can be 100x40. The best effect of printing is to align the number of samples to the console column numbers and convert the amplitude range to the [0, row - 1] range. Configuring the number of samples means configuring the console column size:

#define MAX_CONSOLE_COL 100 // the console max column size
#define NR_SAMPLES MAX_CONSOLE_COL // number of samples in one period

Configure the signal frequency

Change the following macro to configure the desired frequency in HZ units.

#define FREQ_INPUT 50 // 50HZ

Configure the ADC instance

Change the ADC_INST macro to configure the ADC instance you want to use.

#define ADC_INST 0 // ADC0 instance

Change the channel configurations in init_adc() third parameter.

adc_hal_enable(instance, 0, kAdcChannel0, false);

Configure the debug console baudrate.

#define DEBUG_UART_BAUD 115200 // debug uart baudrate